<?php defined('_VALID_MOS') or die('Direct Access to this location is not allowed.'); ?>

<script type="text/javascript">
    function saveRounds(n)
    {
        for (var j = 0; j <= n; j++) {
            box = eval("document.adminForm.cb" + j);
            if (box) {
                if (box.checked == false) {
                    box.checked = true;
                }
            } else {
                alert("You cannot change the order of items, as an item in the list is `Checked Out`");
                return;
            }
        }
        submitform('saveorder');
    }
</script>

<form action="index2.php" method="post" name="adminForm">
    <table cellpadding="4" cellspacing="0" border="0" width="100%">
        <tr>
            <td width="100%" class="sectionname">Rounds <?php echo $this->project->getName(); ?></td>
            <td nowrap="nowrap">
                <fieldset>
                    <legend>From/To/Format</legend>
                    <input type="text" name="round_name_from" value="<?php echo $this->project->getMinRound(); ?>" class="inputbox"  size="4"/>
                    <input type"text" name="round_name_to" value="<?php echo $this->project->getMaxRound(); ?>" class="inputbox" size="4"/>
                           <input type="text" name="round_name_format" value="<?php echo '%02d.Spieltag'; ?>" class="inputbox" />
                    <input type="button" name="" class="button" value="create" onClick="javascript:submitbutton('create');" />
                </fieldset>
            </td>
        </tr>
    </table>

    <table class="adminlist">
        <tr>
            <th width="1%">
                <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->rows); ?>);" />
            </th>
            <th width="5%">Id</th>
            <th width="15%" align="left">Roundname</th>
            <th width="10%" align="left">Shortname</th>
            <th width="5%">Order</th>
            <th>
                <a href="javascript: saveRounds( <?php echo count($this->rows) - 1; ?> )">
                    <img src="images/filesave.png" border="0" width="16" height="16" alt="Save" />
                </a>
            </th>
            <th width="5%">Hits</th>
            <th width="10%">Current</th>
            <th width="5%">ShowResults</th>
            <th width="5%">ShowTable</th>
            <th width="5%">ShowInfo</th>
            <th width="10%" class="title">Shortcuts</th>
            <th width="25%" class="title"></th>
        </tr>
<?php
$i = 0;
foreach ($this->rows as $row) {
    $img = ($this->project->getCurrentRound() == $row->ordering) ? 'tick.png' : 'publish_x.png';
    $showResultImg = $row->showResults == 1 ? 'tick.png' : 'publish_x.png';
    $showTableImg  = $row->showTable == 1 ? 'tick.png' : 'publish_x.png';
    $showInfoImg   = $row->showInfo == 1 ? 'tick.png' : 'publish_x.png';
?>
        <tr class="<?php $this->plugin("toggle", "row0", "row1"); ?>">
            <td align="center">
                <input type="checkbox" id="cb<?php echo $i; ?>" name="cid[]" value="<?php echo $row->round_id; ?>" onclick="isChecked(this.checked);" />
            </td>
            <td align="center"><b><?php echo $row->round_id; ?></b></td>
            <td align="left">
                <a href="#edit" onclick="return listItemTask('cb<?php echo $i; ?>','edit')">
                    <?php echo $row->round_name; ?>
                </a>
            </td>
            <td align="center"><?php echo $row->round_name_short; ?></td>
            <td align="center" colspan="2">
                <input type="text" name="ordering[]" size="5" value="<?php echo $row->ordering; ?>" class="text_area" style="text-align: center" />
            </td>
            <td align="center"><?php echo $row->hits; ?></td>
            <td align="center">
                <a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i; ?>','setcurrent')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo 'Set this round current!'; ?></b>')">
                    <img src="images/<?php echo $img; ?>" width="12" height="12" border="0" alt="" />
                </a>
            </td>

            <td align="center">
                <a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i; ?>','toggleOptionShowResults')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo 'Show Result Tab'; ?></b>')">
                    <img src="images/<?php echo $showResultImg; ?>" width="12" height="12" border="0" alt="" />
                </a>
            </td>

            <td align="center">
                <a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i; ?>','toggleOptionShowTable')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo 'Show Table Tab'; ?></b>')">
                    <img src="images/<?php echo $showTableImg; ?>" width="12" height="12" border="0" alt="" />
                </a>
            </td>

            <td align="center">
                <a href="javascript: void(0);" onclick="return listItemTask('cb<?php echo $i; ?>','toggleOptionShowInfo')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo 'Show Info Tab'; ?></b>')">
                    <img src="images/<?php echo $showInfoImg; ?>" width="12" height="12" border="0" alt="" />
                </a>
            </td>

            <td>
                <a href="#matrix" onclick="return listItemTask('cb<?php echo $i; ?>','matrix')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo $row->round_name; ?></b>: Enter the Matrix!')">
                    <img src="../includes/js/ThemeOffice/mainmenu.png" alt="Matches" title="Matches" border="0" />
                </a>
                &nbsp;
                <a href="#results" onclick="return listItemTask('cb<?php echo $i; ?>','matches')" onmouseover="this.T_DELAY=50;return escape('<b><?php echo $row->round_name; ?></b>: Resultmanager!')">
                    <img src="../includes/js/ThemeOffice/edit.png" alt="Results" title="Results" border="0" />
                </a>
            </td>
            <td>
            <?php if (!$row->content_id): ?>
                <a href="#createarticle" onclick="return listItemTask('cb<?php echo $i; ?>','createarticle')">create Content Article</a>
            <?php else: ?>
                <a href="#editarticle" onclick="return listItemTask('cb<?php echo $i; ?>','editarticle')">edit Content Article</a>
            <?php endif ?>
            </td>
        </tr>
        <?php
                $i++;
            }
        ?>
    </table>

    <input type="hidden" name="option" value="com_leagueman" />
    <input type="hidden" name="act" value="rounds" />
    <input type="hidden" name="task" value="" />
    <input type="hidden" name="boxchecked" value="0" />
</form>